package Commons;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Lenovo
 * Date: 2025-09-05
 * Time: 0:26
 */
public class CommonsFun {
    static File file=null;
    public static void altA(WebDriver driver){
        SimpleDateFormat simdate=new SimpleDateFormat("yyyy-MM-dd");
        SimpleDateFormat simtime=new SimpleDateFormat("HH-mm-ss.SS");
        Date datetime=new Date();
        String date=simdate.format(datetime);
        String time=simtime.format(datetime);
        String name="./src/test/images/"+date+"/"+time+".png";
        try{
            file=((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
            FileUtils.copyFile(file,new File(name));
        }
        catch(IOException e){
            e.printStackTrace();
        }
    }
}
